$(function () {

    $("form").validate({
        rules: {
            uname: {
                required: true,
            },
            upwd: {
                required: true,

            }

        },
        messages: {

            uname: {
                required: "用户名必填",

            },
            upwd: {
                required: "密码必填",

            }

        },
        submitHandler() {

            $.ajax({
                url: "./account/login",
                type: "post",
                data: $("form").serialize()//前端发送到服务器的数据 data
            }).then(function (response) { //服务器响应到前端的数据 response

                if (response.status == 200) {
                    layer.msg("登录成功")
                    setTimeout(function () {
                        location = "index.html";
                    }, 1000)
                } else {
                    layer.msg("登录失败,用户名或密码错误!");
                }
            })

            return false;
        }
    })

})